import './style.css'
import {Tabs} from "antd-mobile";
// 自定义hook 顶部Tabs导航栏
import {useTabs} from "@/hook/useTabs";
import HomeList from "@/pages/Home/HomeList/index";
import {Login} from "@/api/ChannelList.ts";
import {useEffect} from "react";

const Home = () => {
    const {channelList} = useTabs()
    useEffect(() => {
        const getToken = async () => {
            const res = await Login()
            localStorage.setItem('token', res.data.data.token)
        }
        getToken()
    }, []);
    return (
        <div>
            <div className={"tabContainer"}>
                <Tabs defaultActiveKey="0">
                    {channelList.map(item => {
                        // tab区域
                        // @ts-ignore
                        return <Tabs.Tab title={item.name} key={item.id}>
                            {/*/list组件/*/}
                            <div className={"listContainer"}>
                                <HomeList channelId={item.id.toString()}/>
                            </div>
                        </Tabs.Tab>
                    })}
                </Tabs>
            </div>

        </div>
    )
}

export default Home